
import { _decorator, Component, Node } from 'cc';
import Action3dManager, { ActionMngType } from '../../Script/Common/Action3dManager';
import GlobalPool from '../../Script/Common/GlobalPool';
import yyComponent from '../../Script/Common/yyComponent';
const { ccclass, property } = _decorator;

/**爆炸特效 */
@ccclass('Boom')
export class Boom extends yyComponent {

    public reset() {
        Action3dManager.getMng(ActionMngType.Level).stopAllActions(this.node);
    }

    public play(scale: number) {
        let s = scale * 0.4;
        this.node.setScale(s, s, s);
        s = scale * 0.9;
        let scale0 = Action3dManager.scaleTo(0.4, s, s, s);
        scale0.easing(Action3dManager.easeOut(2));
        let cb = Action3dManager.callFun(this.onAnimFinish, this);
        let seq = Action3dManager.sequence(scale0, cb);
        Action3dManager.getMng(ActionMngType.Level).runAction(this.node, seq);
    }
    protected onAnimFinish() {
        GlobalPool.put(this.node);
    }
}
